
// C++ STL
#include <sstream>
// owner
#include "LogMessage.hpp"
#include "Timestamp.hpp"
namespace tulun
{
    // LogMessage::
    // std::string header_;
    // std::string text_;
    // tulun::LOG_LEVEL level_;

    LogMessage::LogMessage(const tulun::LOG_LEVEL &level,
                           const std::string &filename,
                           const std::string &funcname,
                           const int line)
        : header_{}, text_{}, level_{level}
    {
        std::stringstream ss;
        ss << tulun::Timestamp::Now().toFormattedString() << " ";
        ss << tulun::IndexToStr[static_cast<int>(level_)] << " ";
        int pos = filename.rfind('/');
        std::string newfile(filename, pos + 1);
        ss << newfile << " " << funcname << " " << line << " : ";
        header_ = ss.str();
    }
    LogMessage::~LogMessage()
    {
    }
    const tulun::LOG_LEVEL &LogMessage::getLogLevel() const
    {
        return level_;
    }
    const std::string LogMessage::toString() const
    {
        return header_ + text_;
    }

} // namespace tulun